babl-fish-path: add some specific conversion targeted debug info
authorØyvind Kolås <pippin@gimp.org>
Wed, 16 Nov 2016 19:34:05 +0000 (20:34 +0100)
committerØyvind Kolås <pippin@gimp.org>
Sat, 19 Nov 2016 11:52:06 +0000 (12:52 +0100)
babl/babl-cache.c
babl/babl-fish-path.c
babl/babl-util.c
tools/Makefile.am

index 7f0699755668906fd7d8fb767dfd7912fb94e251..4a26db087c15116ef7324fc9064c41e23c721bc1 100644 (file)
@@ -193,6 +193,9 @@ void babl_init_db (void)
   return;
 #endif
 
+  if (getenv ("BABL_DEBUG_CONVERSIONS"))
+    return;
+
   babl_file_get_contents (path, &contents, &length, NULL);
   if (!contents)
     return;
index 25d3bd176a7e8d37a8e093b927cfb135cea72dec..acad60e0c41dd398033779740186da77b1a846a4 100644 (file)
@@ -97,6 +97,7 @@ _babl_fish_create_name (char       *buf,
 
 static int max_path_length (void);
 
+static int debug_conversions = 0;
 
 double _babl_legal_error (void)
 {
@@ -111,6 +112,13 @@ double _babl_legal_error (void)
     error = babl_parse_double (env);
   else
     error = BABL_LEGAL_ERROR;
+
+  env = getenv ("BABL_DEBUG_CONVERSIONS");
+  if (env && env[0] != '\0')
+    debug_conversions = 1;
+  else
+    debug_conversions = 0;
+
   return error;
 }
 
@@ -137,7 +145,6 @@ static int max_path_length (void)
   return max_length;
 }
 
-
 /* The task of BablFishPath construction is to compute
  * the shortest path in a graph where formats are the vertices
  * and conversions are the edges. However, there is an additional
@@ -189,6 +196,13 @@ get_conversion_path (PathContext *pc,
           fpi.destination = pc->to_format;
 
           get_path_instrumentation (&fpi, pc->current_path, &path_cost, &ref_cost, &path_error);
+          if(debug_conversions && current_length == 1)
+            fprintf (stderr, "%s  error:%f cost:%f  \n", 
+                 babl_get_name (pc->current_path->items[0]),
+                 /*babl_get_name (pc->fish_path->fish.source),
+                 babl_get_name (pc->fish_path->fish.destination),*/
+                 path_error,
+                 path_cost /*, current_length*/);
 
           if ((path_cost < ref_cost) && /* do not use paths that took longer to compute than reference */
               (path_cost < pc->fish_path->fish_path.cost) &&
@@ -213,7 +227,6 @@ get_conversion_path (PathContext *pc,
       BablList *list;
       int i;
 
-
       list = current_format->format.from_list;
       if (list)
         {
@@ -375,7 +388,6 @@ babl_fish_path_process (Babl       *babl,
                                   destination,
                                   dest_bpp,
                                   n);
-
 }
 
 static long
@@ -421,7 +433,6 @@ babl_fish_process (Babl       *babl,
         ret = -1;
         break;
     }
-
   return ret;
 }
 
@@ -681,7 +692,7 @@ get_path_instrumentation (FishPathInstrumentation *fpi,
 
   *path_error = babl_rel_avg_error (fpi->destination_rgba_double,
                                     fpi->ref_destination_rgba_double,
-                                    fpi->num_test_pixels * 4);
+                                     fpi->num_test_pixels * 4);
 
 #if 0
   fpi->fish_rgba_to_source->fish.processings--;
index f68a68480a1f181b71d4d8ed4675c024baba122d..b9dd1e4b9ea47bd0163733a7fa91490cdb4eeef2 100644 (file)
@@ -84,7 +84,7 @@ long
 babl_process_cost (long ticks_start,
                    long ticks_end)
 {
-  return (ticks_end - ticks_start) * 10 + 1;
+  return (ticks_end - ticks_start);
 }
 
 double
index ad544558dc3efed4f6adc02e99fd5c27e875c036..1d5075109a6825c4589ea91bcc18da397224fa65 100644 (file)
@@ -3,7 +3,8 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
 LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
        $(MATH_LIB) $(THREAD_LIB)
 
+noinst_PROGRAMS = babl-verify
 if HAVE_SRANDOM
-noinst_PROGRAMS              \
+noinst_PROGRAMS +=             \
        babl-gen-test-pixels
 endif